package systemController

import (
	"CommonsProject/models/systemModel"
	"CommonsProject/pkg/tools/httpTool"
	"CommonsProject/service/commonsService"
	"github.com/gin-gonic/gin"
	http "net/http"
)

type CommonsController struct {
	httpTool.BaseController
	Service *commonsService.CommunalService
}

func (controller *CommonsController) Register(engine *gin.Engine) {
	engine.GET("/captcha", controller.GeneratorCaptcha)
	engine.GET("/login", controller.LoginUser)
}

// LoginUser 用户登录
func (controller *CommonsController) LoginUser(ctx *gin.Context) {
	var user systemModel.SysUser
	controller.ShouldBandingJson(ctx, &user)
	content := controller.Service.LoginUser(ctx, &user)
	ctx.JSON(http.StatusOK, controller.SuccessData(content))
}
